#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a,b;
    cin>>a>>b;
    vector<int> v;
    for(int i=1;i<=3;i++){
        if(a!=i&&b!=i)v.push_back(i);
    }
    if(v.size()>1)cout<<"-1"<<endl;
    if(v.size()==1)cout<<v[0]<<endl;

    return 0;
}